package com.agile.major.service.impl;

import com.agile.major.domain.MajorCoursePlan;
import com.agile.major.repository.MajorCoursePlanRepository;
import com.agile.major.service.MajorCoursePlanService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * Service Implementation for managing MajorCoursePlan.
 */
@Service
@Transactional
public class MajorCoursePlanServiceImpl implements MajorCoursePlanService{

    private final Logger log = LoggerFactory.getLogger(MajorCoursePlanServiceImpl.class);

    private final MajorCoursePlanRepository majorCoursePlanRepository;

    public MajorCoursePlanServiceImpl(MajorCoursePlanRepository majorCoursePlanRepository) {
        this.majorCoursePlanRepository = majorCoursePlanRepository;
    }

    /**
     * Save a majorCoursePlan.
     *
     * @param majorCoursePlan the entity to save
     * @return the persisted entity
     */
    @Override
    public MajorCoursePlan save(MajorCoursePlan majorCoursePlan) {
        log.debug("Request to save MajorCoursePlan : {}", majorCoursePlan);
        return majorCoursePlanRepository.save(majorCoursePlan);
    }

    /**
     *  Get all the majorCoursePlans.
     *
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public Page<MajorCoursePlan> findAll(Pageable pageable) {
        log.debug("Request to get all MajorCoursePlans");
        return majorCoursePlanRepository.findAll(pageable);
    }

    /**
     *  Get one majorCoursePlan by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public MajorCoursePlan findOne(Long id) {
        log.debug("Request to get MajorCoursePlan : {}", id);
        return majorCoursePlanRepository.findOne(id);
    }

    /**
     *  Delete the  majorCoursePlan by id.
     *
     *  @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete MajorCoursePlan : {}", id);
        majorCoursePlanRepository.delete(id);
    }

    @Override
    public Page<MajorCoursePlan> likeCourses(String keyword, Pageable pageable) {
        return majorCoursePlanRepository.findMajorCoursePlanLike(keyword,pageable);
    }
}
